package com.eventapp.model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import javax.persistence.Access;
import javax.persistence.AccessType;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

import com.fasterxml.jackson.annotation.JsonIgnore;

@Entity
@Table(name="events_public")
@Access(AccessType.FIELD)
@PrimaryKeyJoinColumn(name="id")
@XmlRootElement
public class EventPublic extends Event implements Serializable
{
   /** Default value included to remove warning. Remove or modify at will. **/
   private static final long serialVersionUID = 1L;
   

   @OneToMany(cascade=CascadeType.ALL)
   @JoinColumn(name = "event_id")
   private List<Comment> comments;
   

   @ManyToMany(cascade=CascadeType.ALL)
   @JoinTable(
           name = "event_public_likes",
           joinColumns = { @JoinColumn(name = "event_public_id") },
           inverseJoinColumns = @JoinColumn(name = "user_id")
   )
   private Set<User> likes;
   

   @ManyToMany(cascade=CascadeType.ALL)
   @JoinTable(
           name = "event_public_followers",
           joinColumns = { @JoinColumn(name = "event_public_id") },
           inverseJoinColumns = @JoinColumn(name = "user_id")
   )
   private Set<User> followers;
   
   
@Override
public boolean equals(Object o) {
	// TODO Auto-generated method stub
	return false;
}

public List<Comment> getComments() {
	
	return comments;
	
}

public Set<User> getFollowers() {
	return followers;
}

public Set<User> getLikes() {
	return likes;
}
@Override
public int hashCode() {
	// TODO Auto-generated method stub
	return 0;
}
public void setComments(List<Comment> comments) {
	this.comments = comments;

}
public void setFollowers(Set<User> followers) {
	this.followers = followers;
}
public void setLikes(Set<User> likes) {
	this.likes = likes;
}
@Override
public String toString() {
	// TODO Auto-generated method stub
	return null;
}

  public void addComment(Comment comment){
	  if (this.comments==null) {
		this.comments= new ArrayList<Comment>();
	}
	  this.comments.add(comment);
  } 

  public void addLike(User like){
	  if (this.likes==null) {
		this.likes = new HashSet<User>();
	}
	  this.likes.add(like);
  }  

  public void addFollower(User follower){
	  if (this.followers==null) {
		this.followers = new HashSet<User>();
	}
	  this.followers.add(follower);
  }  
   
}